********************************************************************************************************
*                                                                                                      *  
* Are Institutionally Effective Environmental Organizations Also Ecologically Effective?               *
*                                                                                                      *
* Tobias Böhmelt                                                                                       *   
*                                                                                                      *
* This Version: July 16, 2025                                                                          *
*                                                                                                      *
********************************************************************************************************

**************
* Data Setup *
**************

set more off

graph set window fontface "Times New Roman"

set seed 1073741823

use "Final Data 16072025.dta", clear

**********************************
* Descriptive Overview - Table 1 *
**********************************

sum geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy ln_gdppc ln_pop dr_eg

************************
* Fixed Effects Models * 
************************

preserve
eststo clear
eststo: xtreg geographicmeanpm25ugm3 avg_pi i.year, fe r
estimates store reg1
eststo: xtreg geographicmeanpm25ugm3 LDV avg_pi i.year, fe r
estimates store reg2
eststo: xtreg geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year, fe r
estimates store reg3
eststo: xtreg geographicmeanpm25ugm3 avg_pi i.year if e(sample), fe r
estimates store reg4
collapse geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy ln_gdppc ln_pop dr_eg, by(country year)
eststo: xtreg geographicmeanpm25ugm3 avg_pi i.year, fe r
estimates store reg5
eststo: xtreg geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year, fe r
estimates store reg6
esttab reg1 reg2 reg3 reg4 reg5 reg6, se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) 
esttab using "Table1.tex",   /*
 */ se title(Environmental Institutions' Performance)  nonumbers /*
 */ mtitles("Model 1" "Model 2" "Model 3" "Model 4" "Model 5" "Model 6") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors clustered on country in parentheses") replace 
restore 

preserve
tab country, gen(ccode_fe)
tab year, gen(year_fe)
gen gdppc2=ln_gdppc*ln_gdppc
gen gdppc3=ln_gdppc*ln_gdppc*ln_gdppc
estsimp reg geographicmeanpm25ugm3 LDV avg_pi year_fe* ccode_fe*
sum b2, detail
local x1 `r(mean)'
kdensity b2, xli(`x1', lcolor(gs10) lpattern(solid)) legend(off) scheme(538w) aspectratio(1) title("") xtitle("Simulated Marginal Effect") legend(off) note("") name(graph1, replace)
restore

xtreg geographicmeanpm25ugm3 LDV avg_pi i.year, fe r
margins, at(avg_pi=(-2(0.25)1.75)) atmeans level(95)
marginsplot, level(95) recast(line) recastci(rline) legend(off) xlabel(-2(0.25)1.75) scheme(538w) aspectratio(1) name(graph1, replace)

****************************
* Within-Between Estimator *
****************************

global MLwiN_path "C:\Program Files\MLwiN v3.14\mlwin.exe"

preserve

collapse geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy ln_gdppc ln_pop dr_eg, by(country year)
drop if missing(LDV)
drop if missing(avg_pi)
drop if missing(vdem_polyarchy)
drop if missing(ln_gdppc)
drop if missing(ln_pop)
drop if missing(dr_eg)

gen cons=1

sort country
egen LDV_mean = mean(LDV), by(country)
egen avg_pi_mean = mean(avg_pi), by(country)
egen vdem_polyarchy_mean = mean(vdem_polyarchy), by(country)
egen ln_gdppc_mean = mean(ln_gdppc), by(country)
egen ln_pop_mean = mean(ln_pop), by(country)
egen dr_eg_mean = mean(dr_eg), by(country)

gen LDVw = LDV - LDV_mean
gen avg_piw = avg_pi - avg_pi_mean
gen vdem_polyarchyw = vdem_polyarchy - vdem_polyarchy_mean
gen ln_gdppcw = ln_gdppc - ln_gdppc_mean
gen ln_popw = ln_pop - ln_pop_mean
gen dr_egw = dr_eg - dr_eg_mean

xtset country year

runmlwin geographicmeanpm25ugm3 cons LDVw avg_piw vdem_polyarchyw ln_gdppcw ln_popw dr_egw LDV_mean avg_pi_mean vdem_polyarchy_mean ln_gdppc_mean ln_pop_mean dr_eg_mean i.year i.country, level2(country: cons) level1(year: cons) nopause rigls
runmlwin geographicmeanpm25ugm3 cons LDVw avg_piw vdem_polyarchyw ln_gdppcw ln_popw dr_egw LDV_mean avg_pi_mean vdem_polyarchy_mean ln_gdppc_mean ln_pop_mean dr_eg_mean i.year, level2(country: cons) level1(year: cons) nopause rigls
runmlwin geographicmeanpm25ugm3 cons LDVw avg_piw LDV_mean avg_pi_mean i.year i.country, level2(country: cons) level1(year: cons) nopause rigls
runmlwin geographicmeanpm25ugm3 cons LDVw avg_piw LDV_mean avg_pi_mean i.year, level2(country: cons) level1(year: cons) nopause rigls

restore

**********************************
* General Error Correction Model *
**********************************

preserve
collapse geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy ln_gdppc ln_pop dr_eg, by(country year)
replace year=2009 if year==2008
replace year=2015 if year==2014
replace year=2014 if year==2015
replace year=2015 if year==2016
replace year=2016 if year==2017
replace year=2017 if year==2018
sort country year

reg d.geographicmeanpm25ugm3 l.geographicmeanpm25ugm3 d.avg_pi l.avg_pi i.country i.year, r
gen dtotgen = d.geographicmeanpm25ugm3
gen ltotgen = l.geographicmeanpm25ugm3
gen d_cmedianaug = d.avg_pi
gen l_cmedianaug = l.avg_pi
reg dtotgen ltotgen d_cmedianaug l_cmedianaug i.country i.year
dynsim_pcse, dv(geographicmeanpm25ugm3) ldv(ltotgen) ldv_val(25.78471) time(year) pv(country) scen1(d_cmedianaug -.4566938 l_cmedianaug -1.981533) ///
	scen2(d_cmedianaug 2.025783 l_cmedianaug .6120929) command(regress) sims(1000)  ///
	n(9) scheme(538w) ytitle ("Environmental Pollution") legend(label(1 "Weak Performance") label(2 "Strong Performance")) xtitle("Year + t")
restore

**********************************
* Disaggregtation of Performance *
**********************************

preserve
eststo clear
eststo: xtreg geographicmeanpm25ugm3 LDV dfpa income_log partnerships age_log i.year, fe r
estimates store reg1
eststo: xtreg geographicmeanpm25ugm3 LDV djpa income_log partnerships age_log i.year, fe r
estimates store reg2
collapse geographicmeanpm25ugm3 LDV dfpa djpa income_log partnerships age_log, by(country year)
eststo: xtreg geographicmeanpm25ugm3 LDV dfpa income_log partnerships age_log i.year, fe r
estimates store reg3
eststo: xtreg geographicmeanpm25ugm3 LDV djpa income_log partnerships age_log i.year, fe r
estimates store reg4
esttab reg1 reg2 reg3 reg4, se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year)
esttab using "Table4.tex",   /*
 */ se title(Disaggregtation of Environmental Institutions' Performance)  nonumbers /*
 */ mtitles("Model 9" "Model 10" "Model 11" "Model 12") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors clustered on country in parentheses") replace  
restore

*********************
* Robustness Checks *
*********************

preserve
eststo clear
sort country year
by country: replace LDV=populationweightedpm25ugm3[_n-1]
eststo: xtreg populationweightedpm25ugm3 LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year, fe r
estimates store regA1
restore
preserve
sort country year
by country: replace LDV=ef_carb[_n-1]
eststo: xtreg ef_carb LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year, fe r
estimates store regA2
restore
preserve
gen ghg_emissions=ln(en_atm_ghgt_kt_ce)
sort country year
by country: replace LDV=ghg_emissions[_n-1]
eststo: xtreg ghg_emissions LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year, fe r
estimates store regA3
esttab regA1 regA2 regA3, se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) 
esttab using "TableA1.tex",   /*
 */ se title(Environmental Institutions' Performance -- Alternative Dependent Variables)  nonumbers /*
 */ mtitles("Model A1" "Model A2" "Model A3") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors clustered on country in parentheses") replace 
restore

preserve
eststo clear
sum avg_pi
gen select=1 if avg_pi>r(mean)+r(sd) & avg_pi!=.
replace select=0 if select==. & avg_pi!=.
btscs select year country, g(treatyyrs)
probit select vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg c.treatyyrs##c.treatyyrs##c.treatyyrs
estimates store v
reg geographicmeanpm25ugm3 LDV avg_pi i.year i.country if select==1
estimates store z
eststo: suest v z, robust
estimates store regA4
restore
preserve
collapse geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy ln_gdppc ln_pop dr_eg, by(country year)
eststo: xtpcse geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year i.country, correlation(ar1) pair het
estimates store regA5
esttab regA4 regA5, se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.country *.year)
esttab using "TableA2.tex",   /*
 */ se title(Environmental Institutions' Performance -- Alternative Estimation Procedures)  nonumbers /*
 */ mtitles("Model A4" "Model A5") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors clustered on country in parentheses") replace  
restore

preserve
eststo clear
xtile quart = avg_pi, nq(4)
eststo: xtreg geographicmeanpm25ugm3 LDV i.quart vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year, fe r
estimates store regA6
esttab regA6, se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year)
esttab using "TableA3.tex",   /*
 */ se title(Environmental Institutions' Performance -- Disaggregation of Performance)  nonumbers /*
 */ mtitles("Model A6") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors clustered on country in parentheses") replace  
restore

preserve
eststo clear
use "Final Data Sample Selection 16072025.dta", clear
eststo: heckman geographicmeanpm25ugm3 LDV avg_pi c.ln_gdppc##c.ln_gdppc##c.ln_gdppc dr_eg i.year i.country, select(select=vdem_polyarchy ln_pop c.selection_yrs##c.selection_yrs##c.selection_yrs) cluster(ccode)
estimates store regA7
esttab regA7, se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) 
esttab using "TableA4.tex",   /*
 */ se title(Environmental Institutions' Performance -- Selection Model)  nonumbers /*
 */ mtitles("Model A7") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors clustered on country in parentheses") replace 
restore 

preserve
gen ID=1 if treaty=="AF"
replace ID=1 if treaty=="CIFS"
replace ID=1 if treaty=="MLF"
eststo clear
eststo: xtreg geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year if treaty!="AF", fe r
estimates store regA8
eststo: xtreg geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year if treaty!="CIFS" , fe r
estimates store regA9
eststo: xtreg geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year if treaty!="MLF", fe r
estimates store regA10
eststo: xtreg geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year if ID!=1, fe r
estimates store regA11
esttab regA8 regA9 regA10 regA11, se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year)
esttab using "TableA5.tex",   /*
 */ se title(Environmental Institutions' Performance -- Omission of Specific IOs)  nonumbers /*
 */ mtitles("Model A8" "Model A9" "Model A10" "Model A11") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors clustered on country in parentheses") replace  
restore

preserve
collapse geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy ln_gdppc ln_pop dr_eg, by(country year)
xtile quart = avg_pi, nq(4)
gen effectiveness=0 if quart!=.
replace effectiveness=1 if quart>3 & quart!=.
gen ln_gdppc2=ln_gdppc*ln_gdppc
gen ln_gdppc3=ln_gdppc*ln_gdppc*ln_gdppc
fect geographicmeanpm25ugm3, treat(effectiveness) unit(country) time(year) cov(LDV vdem_polyarchy ln_gdppc ln_gdppc2 ln_gdppc3 ln_pop dr_eg) method("fe") force("two-way") se nboots(100)
mat list e(ATT)
mat list e(ATTs)
mat list e(coefs)
restore

preserve
use "Final Data Robustness Contributor 16072025.dta", clear
sum geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy ln_gdppc ln_pop dr_eg
eststo clear
eststo: xtreg geographicmeanpm25ugm3 avg_pi i.year, fe r
estimates store regA13
eststo: xtreg geographicmeanpm25ugm3 LDV avg_pi i.year, fe r
estimates store regA14
eststo: xtreg geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year, fe r
estimates store regA15
eststo: xtreg geographicmeanpm25ugm3 avg_pi i.year if e(sample), fe r
estimates store regA16
collapse geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy ln_gdppc ln_pop dr_eg, by(cname year)
eststo: xtreg geographicmeanpm25ugm3 avg_pi i.year, fe r
estimates store regA17
eststo: xtreg geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg i.year, fe r
estimates store regA18
esttab regA13 regA14 regA15 regA16 regA17 regA18, se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) 
esttab using "TableA7.tex",   /*
 */ se title(Environmental Institutions' Performance -- Placebo Test)  nonumbers /*
 */ mtitles("Model A13" "Model A14" "Model A15" "Model A16" "Model A17" "Model A18") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors clustered on country in parentheses") replace 
restore 

preserve
eststo clear
eststo: xtreg geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg policies_all i.year, fe r
estimates store regA19
eststo: xtreg geographicmeanpm25ugm3 LDV avg_pi vdem_polyarchy c.ln_gdppc##c.ln_gdppc##c.ln_gdppc ln_pop dr_eg policy_air_pollution i.year, fe r
estimates store regA20
esttab regA19 regA20, se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year)
esttab using "TableA8.tex",   /*
 */ se title(Environmental Institutions' Performance -- Domestic Climate Policies)  nonumbers /*
 */ mtitles("Model A19" "Model A20") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors clustered on country in parentheses") replace  
restore